package com.turing.data.scripts.contract.transfer

import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO


/**
 * 场景：资产管理合同
 * 版本：Version 1.0
 * 要素名称：托管费
 */

class CustodyFee_30205_10_transfer {

    static List< TaskElementVO.DrawResultVO > doConvert(List< TaskElementVO.DrawResultVO > resultVOs, DependParamsVO dependParams){

        def regex = /(管理|托管)费.*为(\d+.\d+)%/

        if (resultVOs!=null && resultVOs.size()>0){
            for (int i = 0; i < resultVOs.size(); i++) {
                String modelValue = resultVOs.get(i).getText()
                if (modelValue != null && !modelValue.equals("")) {
                    if(modelValue =~ regex){
                        def value = ( modelValue =~ regex )
                        resultVOs.get(i).setBusinessValue(value[0])
                    }

                    if(modelValue.contains("【")){
                        modelValue = modelValue.substring(modelValue.indexOf("【") , modelValue.length())
                    }

                    if(modelValue.contains("【") || modelValue.contains("】") || modelValue.contains("%")){
                        def businessValue = modelValue.replace("【","")
                                .replace("】","")
                                .replace("%","")
                        resultVOs.get(i).setBusinessValue(businessValue)
                    }
                }
                resultVOs.get(i).setType(1)
            }
        }

        return resultVOs
    }

}
